package utils

import "skedule-backend/config"

// 当前语言
var currentLanguage = "en"

// 文本映射
var texts = map[string]map[string]string{
	"en": {
		// 命令行参数相关
		"flag.version":           "Show version information",
		"flag.version.short":     "Show version information (short)",
		"flag.mode":              "Run mode (server: start server, password: change password)",
		"flag.username":          "Login username",
		"flag.password":          "Login password",
		"flag.jwt.secret":        "JWT secret key",
		"flag.port":              "Server port",
		"flag.config.only":       "Only update configuration, do not start server",
		"flag.show.config":       "Show current configuration",
		"flag.enable.logging":    "Enable API request logging",
		"flag.log.level":         "Log level (debug|info|warn|error)",
		"flag.debug":             "Enable debug mode (show detailed TaskExecution logs)",

		// 服务器启动相关
		"server.starting":           "Starting server...",
		"server.config.loading":     "Loading configuration...",
		"server.config.loaded":      "Configuration loaded successfully",
		"server.config.failed":      "Failed to load configuration: %v",
		"server.database.init":      "Initializing database...",
		"server.database.success":   "Database initialized successfully",
		"server.database.failed":    "Failed to initialize database: %v",
		"server.database.settings.failed": "Failed to initialize default settings: %v",
		"server.logger.init":        "Initializing logger...",
		"server.logger.success":     "Logger initialized successfully",
		"server.logger.failed":      "Failed to initialize logger: %v",
		"server.storage.init":       "Initializing task storage...",
		"server.storage.success":    "Task storage initialized successfully",
		"server.storage.failed":     "Failed to initialize task storage: %v",
		"server.logstore.init":      "Initializing log storage...",
		"server.logstore.success":   "Log storage initialized successfully",
		"server.logstore.failed":    "Failed to initialize log storage: %v",
		"server.execution.init":     "Creating task execution service...",
		"server.execution.success":  "Task execution service created successfully",
		"server.scheduler.init":     "Creating scheduler...",
		"server.scheduler.success":  "Scheduler created successfully",
		"server.scheduler.start":    "Starting scheduler (loading existing tasks)...",
		"server.scheduler.started":  "Scheduler started successfully",
		"server.scheduler.failed":   "Failed to start scheduler: %v",
		"server.nextrun.check":      "Checking task NextRun fields...",
		"server.nextrun.completed":  "Task NextRun fields check completed",
		"server.auth.init":          "Creating authentication configuration...",
		"server.auth.success":       "Authentication configuration created successfully",
		"server.routes.init":        "Setting up routes...",
		"server.routes.success":     "Routes setup completed",
		"server.info.print":         "Printing startup information...",
		"server.started":            "Server started successfully",
		"server.listening":          "Server is listening on %s:%s",
		"server.webui.access":       "Web UI: http://%s:%s",
		"server.credentials":        "Login credentials:",
		"server.username":           "   Username: %s",
		"server.password":           "   Password: %s",
		"server.notes":              "Notes:",
		"server.note.browser":       "   - Use a modern browser to access the web interface",
		"server.note.network":       "   - Ensure firewall allows connections on port %s",
		"server.note.data":          "   - Task data is stored in: %s",

		// 密码相关
		"password.change.success":   "Password changed successfully",
		"password.change.failed":    "Failed to change password: %v",
		"password.new.username":     "   Username: %s",
		"password.new.password":     "   New password: %s (plaintext)",
		"password.encrypted":        "   Encrypted: %s",
		"password.salt":             "   Salt: %s",

		// 配置相关
		"config.current":            "Current configuration:",
		"config.port":               "   Port: %s",
		"config.ip":                 "   IP Address: %s",
		"config.database":           "   Database: %s",
		"config.username":           "   Username: %s",
		"config.password.encrypted": "   Password: %s (encrypted)",
		"config.salt":               "   Salt: %s",
		"config.updated":            "Configuration updated, will take effect on next startup",
		"config.updating":           "Updating configuration...",

		// 调试模式
		"debug.enabled":             "Debug mode: Enabled (will show detailed TaskExecution logs)",
		"debug.disabled":            "Debug mode: Disabled",

		// 日志相关
		"logging.enabled":           "Logging: Enabled (level: %s)",
		"logging.disabled":          "Logging: Disabled",
		"logging.file":              "Log file: [executable_dir]/logs/api_%s.log",
		"logging.detail":            "Log detail level:",
		"logging.detail.debug":      "   - Records all request headers, parameters, request body, response content",
		"logging.detail.info":       "   - Records query parameters and request body",
		"logging.detail.warn":       "   - Records only basic request information",

		// 错误消息
		"error.mode.invalid":        "Invalid mode: %s",
		"error.config.not.found":    "Configuration file not found, creating default config: %s",
		"error.config.load.failed":  "Failed to load configuration: %v",

		// 任务相关
		"task.created":              "Task created successfully",
		"task.updated":              "Task updated successfully",
		"task.deleted":              "Task deleted successfully",
		"task.executed":             "Task execution started",
		"task.stopped":              "Task execution stopped",
		"task.enabled":              "Task enabled",
		"task.disabled":             "Task disabled",

		// API响应
		"api.success":               "Success",
		"api.error":                 "Error",
		"api.unauthorized":          "Unauthorized",
		"api.not.found":             "Not found",
		"api.bad.request":           "Bad request",
		"api.internal.error":        "Internal server error",

		// 任务执行相关
		"task.execution.started":    "=== Task execution started ===",
		"task.execution.stopped":    "Task stopped by user",
		"task.execution.env":        "Execution environment: %s",
		"task.execution.os":         "Operating system: %s/%s",
		"task.not.found":            "Task not found: %s",
		"task.execution.command.empty": "Error: Command cannot be empty",
		"task.execution.command":    "Executing command: %s",
		"task.execution.start.time": "Start time: %s",
		"task.debug.stop.lastrun.failed": "Failed to update database LastRun when stopping task: taskId=%s, error=%v",
		"task.debug.stop.lastrun.success": "Updated database LastRun when stopping task: taskId=%s, lastRun=%s",
		"task.debug.websocket.start": "Broadcasting WebSocket execution start event: executionId=%s",
		"task.debug.websocket.complete": "Broadcasting WebSocket execution complete event: executionId=%s, status=%s",
		"task.debug.lastrun.update.failed": "Failed to update database LastRun: taskId=%s, error=%v",
		"task.debug.lastrun.update.success": "Updated database LastRun: taskId=%s, lastRun=%s",
		"task.debug.output.reading.start": "Starting to read output stream: executionId=%s",
		"task.debug.output.line": "Read line %d output: executionId=%s, line=%s",
		"task.debug.websocket.output": "Broadcasting WebSocket output update: executionId=%s, line=%s",
		"task.debug.websocket.empty": "WebSocket handler is empty, cannot broadcast",
		"task.debug.execution.notfound": "Execution record not found: executionId=%s",
		"task.debug.output.error": "Error reading output stream: executionId=%s, error=%v",
		"task.debug.output.complete": "Output stream reading completed: executionId=%s, total lines=%d",

		// 任务迁移相关
		"migration.query.failed":    "Failed to query tasks for migration: %v",
		"migration.no.tasks":        "No tasks need NextRun migration",
		"migration.found.tasks":     "Found %d enabled tasks that need NextRun calculation",
		"migration.update.failed":   "Failed to update task [%s] NextRun: %v",
		"migration.update.success":  "Calculated NextRun for task [%s]: %s",
		"migration.cron.invalid":    "Invalid Cron expression for task [%s]: %v",

		// 网络相关
		"network.ip.unknown":        "Unknown",

		// 存储相关
		"storage.log.not.found":     "Log not found: %s",

		// 认证相关
		"auth.config.get.failed":    "Failed to get configuration: %v",
		"auth.username.incorrect":   "Username is incorrect",
		"auth.request.invalid":      "Invalid request format",
		"auth.credentials.invalid":  "Invalid username or password",
		"auth.token.generate.failed": "Failed to generate token",
		"auth.login.success":        "Login successful",
		"auth.password.old.incorrect": "Old password is incorrect",
		"auth.password.update.failed": "Failed to update password: %s",
		"auth.password.change.success": "Password changed successfully",

		// 配置文件相关
		"config.file.read.failed":   "Failed to read configuration file: %v",
		"config.file.parse.failed":  "Failed to parse configuration file: %v",
		"config.file.write.failed":  "Failed to write configuration file: %v",
		"config.serialize.failed":   "Failed to serialize configuration: %v",
		"config.path.get.failed":    "Failed to get configuration file path: %v",
		"config.save.default.failed": "Failed to save default configuration: %v",
		"config.validation.failed": "Configuration validation failed: %v",
		"config.ip.empty":           "IP address cannot be empty",
		"config.port.empty":         "Port cannot be empty",
		"config.database.path.empty": "Database path cannot be empty",

		// 调度器相关
		"scheduler.task.save.failed": "Failed to save task: %v",
		"scheduler.task.schedule.failed": "Failed to schedule task: %v",
		"scheduler.task.update.failed": "Failed to update task: %v",
		"scheduler.task.reschedule.failed": "Failed to reschedule task: %v",
		"scheduler.task.get.failed": "Failed to get task: %v",
		"scheduler.task.status.update.failed": "Failed to update task status: %v",
		"scheduler.cron.add.failed": "Failed to add cron job: %v",

		// 中间件相关
		"middleware.log.dir.create.failed": "Failed to create log directory: %w",
		"middleware.log.file.open.failed": "Failed to open log file: %w",
		"middleware.auth.header.missing": "Missing Authorization header",
		"middleware.auth.format.invalid": "Invalid Authorization format",
		"middleware.auth.token.invalid": "Invalid token",

		// 任务处理相关
		"handler.task.running": "Task is currently running, executionId: %s",
		"handler.duration.format.days": "%d days %d hours %d minutes",
		"handler.duration.format.hours": "%d hours %d minutes",
		"handler.duration.format.minutes": "%d minutes",

		// 日志处理相关
		"logs.get.failed": "获取日志失败",
		"logs.task.get.failed": "获取任务日志失败",
		"logs.cleanup.failed": "清理日志失败",
		"logs.cleanup.success": "日志清理完成",

		// 任务API相关
		"tasks.list.get.failed": "获取任务列表失败",
		"tasks.not.found": "任务不存在",
		"tasks.request.invalid": "无效的请求格式",
		"tasks.schedule.empty": "调度规则不能为空",
		"tasks.save.failed": "保存任务失败: %s",
		"tasks.create.success": "任务创建成功",
		"tasks.update.failed": "更新任务失败",
		"tasks.scheduler.update.failed": "更新调度器失败: %s",
		"tasks.update.success": "任务更新成功",
		"tasks.delete.failed": "删除任务失败",
		"tasks.delete.success": "任务删除成功",
		"tasks.toggle.failed": "切换任务状态失败: %s",
		"tasks.status.get.failed": "获取更新后的任务状态失败",
		"tasks.disabled": "任务已禁用",
		"tasks.enabled": "任务已启用",
		"tasks.stop.failed": "停止任务失败: %s",
		"tasks.stop.request.sent": "任务停止请求已发送",
		"tasks.execute.failed": "执行任务失败: %s",
		"tasks.execute.success": "任务执行成功",
		"tasks.execute.request.sent": "任务执行请求已发送",
		"tasks.execution.get.failed": "获取执行记录失败: %s",
		"tasks.execution.service.unavailable": "执行服务不可用",
		"tasks.pin.update.failed": "更新任务置顶状态失败",
		"tasks.pin.unpinned": "任务已取消置顶",
		"tasks.pin.pinned": "任务已置顶",

		// 设置API相关
		"settings.get.failed": "获取设置失败",
		"settings.request.invalid": "无效的请求格式",
		"settings.current.get.failed": "获取现有设置失败",
		"settings.save.failed": "保存设置失败",
		"settings.update.success": "设置更新成功",

		// 版本信息相关
		"version.app.name": "Skedule - Cross-platform Task Scheduler",
		"version.version": "Version: %s",
		"version.build.date": "Build Date: %s",
		"version.git.commit": "Git Commit: %s",
		"version.go.version": "Go Version: %s",
		"version.os.arch": "OS/Arch: %s/%s",
		"version.copyright": "Copyright (c) 2024 Skedule Project",
	},
	"zh": {
		// 命令行参数相关
		"flag.version":           "显示版本信息",
		"flag.version.short":     "显示版本信息 (简写)",
		"flag.mode":              "运行模式 (server: 启动服务器, password: 修改密码)",
		"flag.username":          "登录用户名",
		"flag.password":          "登录密码",
		"flag.jwt.secret":        "JWT密钥",
		"flag.port":              "服务器端口",
		"flag.config.only":       "仅更新配置，不启动服务器",
		"flag.show.config":       "显示当前配置",
		"flag.enable.logging":    "启用API请求日志",
		"flag.log.level":         "日志级别 (debug|info|warn|error)",
		"flag.debug":             "启用调试模式 (显示详细的TaskExecution日志)",

		// 服务器启动相关
		"server.starting":           "开始启动服务器...",
		"server.config.loading":     "正在加载配置...",
		"server.config.loaded":      "配置加载成功",
		"server.config.failed":      "加载配置失败: %v",
		"server.database.init":      "正在初始化数据库...",
		"server.database.success":   "数据库初始化完成",
		"server.database.failed":    "数据库初始化失败: %v",
		"server.database.settings.failed": "Failed to initialize default settings: %v",
		"server.logger.init":        "正在初始化日志记录器...",
		"server.logger.success":     "日志记录器初始化完成",
		"server.logger.failed":      "初始化日志记录器失败: %v",
		"server.storage.init":       "正在初始化任务存储...",
		"server.storage.success":    "任务存储初始化完成",
		"server.storage.failed":     "初始化任务存储失败: %v",
		"server.logstore.init":      "正在初始化日志存储...",
		"server.logstore.success":   "日志存储初始化完成",
		"server.logstore.failed":    "初始化日志存储失败: %v",
		"server.execution.init":     "正在创建任务执行服务...",
		"server.execution.success":  "任务执行服务创建完成",
		"server.scheduler.init":     "正在创建调度器...",
		"server.scheduler.success":  "调度器创建完成",
		"server.scheduler.start":    "正在启动调度器（加载已有任务）...",
		"server.scheduler.started":  "调度器启动完成",
		"server.scheduler.failed":   "启动调度器失败: %v",
		"server.nextrun.check":      "正在检查任务NextRun字段...",
		"server.nextrun.completed":  "任务NextRun字段检查完成",
		"server.auth.init":          "正在创建认证配置...",
		"server.auth.success":       "认证配置创建完成",
		"server.routes.init":        "正在设置路由...",
		"server.routes.success":     "路由设置完成",
		"server.info.print":         "正在打印启动信息...",
		"server.started":            "服务器启动成功",
		"server.listening":          "服务器正在监听 %s:%s",
		"server.webui.access":       "Web界面访问地址: http://%s:%s",
		"server.credentials":        "登录凭据:",
		"server.username":           "   用户名: %s",
		"server.password":           "   密码: %s",
		"server.notes":              "注意事项:",
		"server.note.browser":       "   - 请使用现代浏览器访问Web界面",
		"server.note.network":       "   - 确保防火墙允许端口 %s 的连接",
		"server.note.data":          "   - 任务数据存储在: %s",

		// 密码相关
		"password.change.success":   "密码修改成功",
		"password.change.failed":    "修改密码失败: %v",
		"password.new.username":     "   用户名: %s",
		"password.new.password":     "   新密码: %s (明文)",
		"password.encrypted":        "   加密后: %s",
		"password.salt":             "   盐值: %s",

		// 配置相关
		"config.current":            "当前配置:",
		"config.port":               "   端口: %s",
		"config.ip":                 "   IP地址: %s",
		"config.database":           "   数据库: %s",
		"config.username":           "   用户名: %s",
		"config.password.encrypted": "   密码: %s (已加密)",
		"config.salt":               "   盐值: %s",
		"config.updated":            "配置已更新，下次启动时生效",
		"config.updating":           "更新配置信息...",

		// 调试模式
		"debug.enabled":             "调试模式: 已启用 (将显示详细的TaskExecution日志)",
		"debug.disabled":            "调试模式: 已禁用",

		// 日志相关
		"logging.enabled":           "日志记录: 已启用 (级别: %s)",
		"logging.disabled":          "日志记录: 已禁用",
		"logging.file":              "日志文件: [executable_dir]/logs/api_%s.log",
		"logging.detail":            "日志详细程度:",
		"logging.detail.debug":      "   - 记录所有请求头、参数、请求体、响应内容",
		"logging.detail.info":       "   - 记录查询参数和请求体",
		"logging.detail.warn":       "   - 仅记录基本请求信息",

		// 错误消息
		"error.mode.invalid":        "无效的运行模式: %s",
		"error.config.not.found":    "配置文件不存在，创建默认配置: %s",
		"error.config.load.failed":  "加载配置失败: %v",

		// 任务相关
		"task.created":              "任务创建成功",
		"task.updated":              "任务更新成功",
		"task.deleted":              "任务删除成功",
		"task.executed":             "任务开始执行",
		"task.stopped":              "任务执行已停止",
		"task.enabled":              "任务已启用",
		"task.disabled":             "任务已禁用",

		// API响应
		"api.success":               "成功",
		"api.error":                 "错误",
		"api.unauthorized":          "未授权",
		"api.not.found":             "未找到",
		"api.bad.request":           "请求错误",
		"api.internal.error":        "内部服务器错误",

		// 任务执行相关
		"task.execution.started":    "=== 任务执行开始 ===",
		"task.execution.stopped":    "任务已被用户手动停止",
		"task.execution.env":        "执行环境: %s",
		"task.execution.os":         "操作系统: %s/%s",
		"task.not.found":            "任务不存在: %s",
		"task.execution.command.empty": "错误: 命令不能为空",
		"task.execution.command":    "执行命令: %s",
		"task.execution.start.time": "开始时间: %s",
		"task.debug.stop.lastrun.failed": "停止任务时更新数据库LastRun失败: taskId=%s, error=%v",
		"task.debug.stop.lastrun.success": "停止任务时已更新数据库LastRun: taskId=%s, lastRun=%s",
		"task.debug.websocket.start": "推送WebSocket执行开始事件: executionId=%s",
		"task.debug.websocket.complete": "推送WebSocket执行完成事件: executionId=%s, status=%s",
		"task.debug.lastrun.update.failed": "更新数据库LastRun失败: taskId=%s, error=%v",
		"task.debug.lastrun.update.success": "已更新数据库LastRun: taskId=%s, lastRun=%s",
		"task.debug.output.reading.start": "开始读取输出流: executionId=%s",
		"task.debug.output.line": "读取到第%d行输出: executionId=%s, line=%s",
		"task.debug.websocket.output": "推送WebSocket输出更新: executionId=%s, line=%s",
		"task.debug.websocket.empty": "WebSocket处理器为空，无法推送",
		"task.debug.execution.notfound": "执行记录不存在: executionId=%s",
		"task.debug.output.error": "读取输出流错误: executionId=%s, error=%v",
		"task.debug.output.complete": "输出流读取完成: executionId=%s, 总行数=%d",

		// 任务迁移相关
		"migration.query.failed":    "查询需要迁移的任务失败: %v",
		"migration.no.tasks":        "没有需要迁移NextRun的任务",
		"migration.found.tasks":     "发现 %d 个启用的任务需要计算NextRun",
		"migration.update.failed":   "更新任务 [%s] NextRun失败: %v",
		"migration.update.success":  "已为任务 [%s] 计算NextRun: %s",
		"migration.cron.invalid":    "任务 [%s] 的Cron表达式无效: %v",

		// 网络相关
		"network.ip.unknown":        "未知",

		// 存储相关
		"storage.log.not.found":     "日志不存在: %s",

		// 认证相关
		"auth.config.get.failed":    "获取配置失败: %v",
		"auth.username.incorrect":   "用户名不正确",
		"auth.request.invalid":      "无效的请求格式",
		"auth.credentials.invalid":  "用户名或密码错误",
		"auth.token.generate.failed": "生成token失败",
		"auth.login.success":        "登录成功",
		"auth.password.old.incorrect": "原密码错误",
		"auth.password.update.failed": "密码更新失败: %s",
		"auth.password.change.success": "密码修改成功",

		// 配置文件相关
		"config.file.read.failed":   "读取配置文件失败: %v",
		"config.file.parse.failed":  "解析配置文件失败: %v",
		"config.file.write.failed":  "写入配置文件失败: %v",
		"config.serialize.failed":   "序列化配置失败: %v",
		"config.path.get.failed":    "获取配置文件路径失败: %v",
		"config.save.default.failed": "保存默认配置失败: %v",
		"config.validation.failed": "配置验证失败: %v",
		"config.ip.empty":           "监听IP地址不能为空",
		"config.port.empty":         "端口不能为空",
		"config.database.path.empty": "数据库路径不能为空",

		// 调度器相关
		"scheduler.task.save.failed": "保存任务失败: %v",
		"scheduler.task.schedule.failed": "调度任务失败: %v",
		"scheduler.task.update.failed": "更新任务失败: %v",
		"scheduler.task.reschedule.failed": "重新调度任务失败: %v",
		"scheduler.task.get.failed": "获取任务失败: %v",
		"scheduler.task.status.update.failed": "更新任务状态失败: %v",
		"scheduler.cron.add.failed": "添加定时任务失败: %v",

		// 中间件相关
		"middleware.log.dir.create.failed": "创建日志目录失败: %w",
		"middleware.log.file.open.failed": "打开日志文件失败: %w",
		"middleware.auth.header.missing": "缺少Authorization头",
		"middleware.auth.format.invalid": "无效的Authorization格式",
		"middleware.auth.token.invalid": "无效的token",

		// 任务处理相关
		"handler.task.running": "任务正在运行中，executionId: %s",
		"handler.duration.format.days": "%d天 %d小时 %d分钟",
		"handler.duration.format.hours": "%d小时 %d分钟",
		"handler.duration.format.minutes": "%d分钟",

		// 日志处理相关
		"logs.get.failed": "获取日志失败",
		"logs.task.get.failed": "获取任务日志失败",
		"logs.cleanup.failed": "清理日志失败",
		"logs.cleanup.success": "日志清理完成",

		// 任务API相关
		"tasks.list.get.failed": "Failed to get task list",
		"tasks.not.found": "Task not found",
		"tasks.request.invalid": "Invalid request format",
		"tasks.schedule.empty": "Schedule rule cannot be empty",
		"tasks.save.failed": "Failed to save task: %s",
		"tasks.create.success": "Task created successfully",
		"tasks.update.failed": "Failed to update task",
		"tasks.scheduler.update.failed": "Failed to update scheduler: %s",
		"tasks.update.success": "Task updated successfully",
		"tasks.delete.failed": "Failed to delete task",
		"tasks.delete.success": "Task deleted successfully",
		"tasks.toggle.failed": "Failed to toggle task status: %s",
		"tasks.status.get.failed": "Failed to get updated task status",
		"tasks.disabled": "Task disabled",
		"tasks.enabled": "Task enabled",
		"tasks.stop.failed": "Failed to stop task: %s",
		"tasks.stop.request.sent": "Task stop request sent",
		"tasks.execute.failed": "Failed to execute task: %s",
		"tasks.execute.success": "Task execution started",
		"tasks.execute.request.sent": "Task execution request sent",
		"tasks.execution.get.failed": "Failed to get execution record: %s",
		"tasks.execution.service.unavailable": "Execution service unavailable",
		"tasks.pin.update.failed": "Failed to update task pin status",
		"tasks.pin.unpinned": "Task unpinned",
		"tasks.pin.pinned": "Task pinned",

		// 设置API相关
		"settings.get.failed": "获取设置失败",
		"settings.request.invalid": "无效的请求格式",
		"settings.current.get.failed": "获取现有设置失败",
		"settings.save.failed": "保存设置失败",
		"settings.update.success": "设置更新成功",

		// 版本信息相关
		"version.app.name": "Skedule - 跨平台任务调度器",
		"version.version": "版本: %s",
		"version.build.date": "构建日期: %s",
		"version.git.commit": "Git提交: %s",
		"version.go.version": "Go版本: %s",
		"version.os.arch": "操作系统/架构: %s/%s",
		"version.copyright": "版权所有 (c) 2024 Skedule 项目",
	},
}

// InitI18n 初始化国际化
func InitI18n(cfg *config.Config) {
	if cfg.Language == "zh" || cfg.Language == "zh-CN" {
		currentLanguage = "zh"
	} else {
		currentLanguage = "en"
	}
}

// T 获取国际化文本
func T(key string) string {
	if text, exists := texts[currentLanguage][key]; exists {
		return text
	}
	// 如果当前语言没有找到，回退到英文
	if text, exists := texts["en"][key]; exists {
		return text
	}
	// 如果都没找到，返回key本身
	return key
}

// GetCurrentLanguage 获取当前语言
func GetCurrentLanguage() string {
	return currentLanguage
}

// SetLanguage 设置语言
func SetLanguage(lang string) {
	if lang == "zh" || lang == "zh-CN" {
		currentLanguage = "zh"
	} else {
		currentLanguage = "en"
	}
} 